/*
 * Copyright (C) 2018 Baidu, Inc. All Rights Reserved.
 */
package com.hongye.jpademo;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

import lombok.Data;

@Data
public class UserAddForm {

    @NotNull(message = "用户Id不能为空")
    @Positive(message = "用户ID必须为正数")
    private Long userId;

    @NotEmpty(message = "用户名称不能为空")
    private String userName;

    @NotNull(message = "用户年龄不能为空")
    @Positive(message = "用户年龄必须为正数")
    private Integer age;

    public User toUser() {
        User user = new User();
        user.setAge(age);
        user.setUserId(userId);
        user.setUserName(userName);
        return user;
    }

}
